package com.atguigu.spzx.user.service.impl;

import com.atguigu.spzx.common.utils.AuthContextUtil;
import com.atguigu.spzx.model.entity.user.UserAddress;
import com.atguigu.spzx.model.entity.user.UserInfo;
import com.atguigu.spzx.user.mapper.UserAddressMapper;
import com.atguigu.spzx.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserAddressServiceImpl implements UserAddressService {

    @Autowired
    UserAddressMapper userAddressMapper;

    @Override
    public List<UserAddress> findUserAddressList() {
        //获取用户ID
        UserInfo userInfo = AuthContextUtil.getUserInfo();
        Long userId = userInfo.getId();
        List<UserAddress> userAddressList = userAddressMapper.findUserAddressListById(userId);
        return userAddressList;
    }

    @Override
    public UserAddress getUserAddressById(Long userAddressId) {
        UserAddress userAddress= userAddressMapper.findUserAddressById(userAddressId);
        return userAddress;
    }
}
